﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Domain.MainModule.Entities;
using Infraestructure.Data.MainModule.UnitOfWork;
using Infraestructure.CrossCutting.Logging;
using Domain.MainModule.CreditCards;
using Infraestructure.Data.MainModule.Repositories;

namespace Infraestructure.Data.MainModule.Tests.RepositoriesTests
{
    /// <summary>
    ///This is a test class for CreditCardRepositoryTest and is intended
    ///to contain all CreditCardRepositoryTest Unit Tests
    ///</summary>
    [TestClass()]
    public class CreditCardRepositoryTest : RepositoryTestsBase<CreditCard>
    {
       public override System.Linq.Expressions.Expression<Func<CreditCard, bool>> FilterExpression
        {
            get { return a => a.CreditCardId == TestConstants.Instance.CREDIT_CARD_ID; }
        }

        public override System.Linq.Expressions.Expression<Func<CreditCard, Guid>> OrderByExpression
        {
            get { return a => a.CreditCardId; }
        }

        /// <summary>
        ///A test for FindCreditCard
        ///</summary>
        [TestMethod()]
        public void FindCreditCardById_Invoke_Test()
        {
            //Arrange 
            IMainModuleUnitOfWork context = GetUnitOfWork();
            ITraceManager traceManager = this.GetTraceManager();
            ICreditCardRepository repository = new CreditCardRepository(context, traceManager);

            CreditCardIdSpecification spec = new CreditCardIdSpecification(TestConstants.Instance.CREDIT_CARD_ID);

            //Act
            CreditCard creditCard = repository.FindCreditCard(spec);

            //Assert
            Assert.IsNotNull(creditCard);
        }

        /// <summary>
        ///A test for FindCreditCard
        ///</summary>
        [TestMethod()]
        public void FindCreditCardByUserId_Invoke_Test()
        {
            //Arrange 
            IMainModuleUnitOfWork context = GetUnitOfWork();
            ITraceManager traceManager = this.GetTraceManager();
            ICreditCardRepository repository = new CreditCardRepository(context, traceManager);

            CreditCardUserIdSpecification spec = new CreditCardUserIdSpecification(TestConstants.Instance.USER_ID);

            //Act
            IEnumerable<CreditCard> creditCard = repository.FindCreditCards(spec);

            //Assert
            Assert.IsNotNull(creditCard);
        }
    }
}
